/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.wisnu.spms.service.util;

import com.wisnu.spms.service.dao.DbBillingDao;
import com.wisnu.spms.service.dao.DbBillingTypeDao;
import com.wisnu.spms.service.dao.DbEmployeeDao;
import com.wisnu.spms.service.dao.DbPaymentDao;
import com.wisnu.spms.service.dao.DbStudentDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 * @author Wisnu Wardoyo
 */
public final class SpringUtil {

    private static ApplicationContext applicationContext;

    public static ApplicationContext getApplicationContext() {
        if (applicationContext == null) {
            applicationContext = new ClassPathXmlApplicationContext("com/wisnu/spms/service/SpringXMLConfig.xml");
        }
        return applicationContext;
    }

    public static DbStudentDao getDbStudentDao() {
        return (DbStudentDao) getApplicationContext().getBean("studentDao");
    }

    public static DbPaymentDao getDbPaymentDao() {
        return (DbPaymentDao) getApplicationContext().getBean("paymentDao");
    }

    public static DbBillingDao getBillingDao() {
        return (DbBillingDao) getApplicationContext().getBean("billingDao");
    }

    public static DbEmployeeDao getDbEmployeeDao() {
        return (DbEmployeeDao) getApplicationContext().getBean("employeeDao");
    }
    
    public static DbBillingTypeDao getBillingTypeDao(){
        return (DbBillingTypeDao) getApplicationContext().getBean("billingTypeDao");
    }

}
